package net.jkdmanager.server.services.agents;

import java.io.Serializable;

import net.jkdmanager.common.api.messages.ConfigurationMessage;
import net.jkdmanager.common.api.messages.ConfigurationRequestMessage;
import net.jkdmanager.common.services.messaging.MessageListener;
import net.jkdmanager.common.services.messaging.MessagingService;
import net.jkdmanager.server.services.model.ModelService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("agentConfigurationProviderService")
public class AgentConfigurationProviderServiceImpl implements MessageListener {

	@Autowired
	private ModelService modelService;
	
	@Autowired
	private MessagingService messagingService;
	
	public void receiveMessage(Serializable message) {
		if (message instanceof ConfigurationRequestMessage) {
			messagingService.sendMessage(new ConfigurationMessage(modelService.getAllApplications()));
		}
	}
	
}
